import HomeView from '@/views/HomeView.vue'
import BlankLayout from '@/layouts/BlankLayout.vue'
import UserLoginView from '@/views/user/UserLoginView.vue'
import BasicLayout from '@/layouts/MainLayout.vue'

/**
 * 导航栏菜单页
 */
export const appRouter = [
  {
    path: '/home',
    name: '首页',
    component: HomeView,
    meta: {
      icon: 'House',
    }
  },
  {
    path: '/sys',
    name: '系统管理',
    meta: {
      icon: 'Setting',
    },
    children: [
      {
        path: '/sys/user',
        name: '用户管理',
        component: () => import('../views/sys/UserList.vue'),
        meta: {
          icon: 'User',
        }
      },
      {
        path: '/system/role',
        name: '角色管理',
        component: () => import('../views/TestView.vue'),
        meta: {
          icon: 'Avatar',
        }
      }
    ]
  },
  {
    path: '/test',
    name: '测试页面',
    component: () => import('../views/TestView.vue'),
    meta: {
      icon: 'Tools',
    }
  },
  {
    path: '/book',
    name: 'CRUD模板',
    component: () => import('../views/book/list.vue'),
    meta: {
      icon: 'Edit',
    }
  },
  {
    path: '/about',
    name: '项目说明',
    component: () => import('../views/AboutView.vue'),
    meta: {
      icon: 'Flag',
    }
  },
]

export const routes = [
  {
    path: '/',
    component: BasicLayout,
    redirect: '/home',
    children: appRouter,
  },
  {
    path: '/user',
    name: '用户',
    component: BlankLayout,
    children: [
      {
        path: '/user/login',
        name: '用户登录',
        component: UserLoginView,
      },
    ],
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: '/403',
    name: '无权限',
    component: () => import('@/views/error/403.vue'),
    meta: {
      hideInMenu: true,
    },
  },
  {
    path: '/:pathMatch(.*)*',
    name: '未找到',
    component: () => import('@/views/error/404.vue'),
    meta: {
      hideInMenu: true,
    },
  },
]
